package com.ma.implatform.utils;

import org.springframework.util.ReflectionUtils;

public final class BeanUtils {
    private BeanUtils(){}

    private static void handleReflectionException(Exception e) {
        ReflectionUtils.handleReflectionException(e);
    }
    /**
     * 属性拷贝
     */
    public static <T> T copyProperties(Object orig,Class<T> destClass){
        try {
            T tatget = destClass.newInstance();
            if (orig == null){
                return null;
            }
            copyProperties(orig,tatget);
            return tatget;
        }catch (Exception e){
            handleReflectionException(e);
            return null;
        }
    }
    public static void copyProperties(Object orig,Object dest){
        try {
            org.springframework.beans.BeanUtils.copyProperties(orig,dest);
        }catch (Exception e){
            handleReflectionException(e);
        }
    }
}
